package main

import (
	"fmt"
	"grpc-jwt-yonghurenzheng/v1.0_session_cookies/config"
	"grpc-jwt-yonghurenzheng/v1.0_session_cookies/handlers"
	"log"
	"net/http"

	"github.com/gorilla/mux"
)

func main() {
	config.InitDB()
	r := mux.NewRouter()

	r.HandleFunc("/register", handlers.Register).Methods("POST")
	r.HandleFunc("/login", handlers.Login).Methods("POST")
	r.HandleFunc("/logout", handlers.Logout).Methods("POST")
	r.HandleFunc("/profile", handlers.Profile).Methods("GET") // 新增受保护的路由
	r.HandleFunc("/delete_user", handlers.DeleteUser).Methods("DELETE")

	fmt.Println("🚀 V1 (Session/Cookie) 服务启动于 http://localhost:8080")
	log.Fatal(http.ListenAndServe(":8080", r))
}
